<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 2019-06-14
 * Time: 12:16
 */

ini_set('display_errors', 1);
ini_set('memory_limit', -1);

error_reporting(0);
require_once '/data/wwwroot/g_vendor/autoload.php';


$orderPackageList = \Biz\model\trade\OrderPackage::select("*", ["id[>]" => 2048]);

if (empty($orderPackageList)) {
    return;
}

foreach ($orderPackageList as $orderPackage) {
    $orderInfo = \Biz\model\trade\Order::getOrderInfo($orderPackage['order_no']);

    if (empty($orderInfo)) {
        continue;
    }

    if($orderInfo['is_package_delivery']){
        continue;
    }


    //修复is_package_delivery没有修改成1的问题
    if (!$orderInfo['is_package_delivery']) {
        \Biz\model\trade\Order::update(["is_package_delivery" => 1], ["order_no" => $orderInfo['order_no']]);
    }

    //修复发货时间错误
    if ($orderInfo['delivery_time'] != $orderPackage['delivery_time']) {
        \Biz\model\trade\OrderPackage::update(["delivery_time" => $orderInfo['delivery_time']], ["id" => $orderPackage['id']]);
    }
}